package ModelLayer;
import java.util.ArrayList;


public class Customers
{
    //instance variables
    private static Customers instance = null;
    private static ArrayList<Customer> customers;

    /**
     * Empty constructor for testing purposes
     */
    
    public Customers()
    {
        customers = new ArrayList<Customer>();
    }
    
    /**
     * Singleton static inplementation
     */
    
    public static Customers getInstance()
    {
        if(instance == null)
        {
            instance = new Customers();
        }
        return instance;
    }
    
    /**
     * Accessor and Mutator methods
     */
    
    public static void addCustomer(Customer _customer)
    {
        customers.add(_customer);
    }
    
    public static Customer getCustomer(String _id)
    {
        Customer c = new Customer();
        for(int i = 0; i<customers.size(); i++)
        {
            if(customers.get(i).getId().equals(_id))
                c = customers.get(i);
        }
        return c;
    }
    
    public static void printCustomers()
    {
        System.out.println("\nCustomers:");
        for(int i = 0; i < customers.size(); i++)
        {
            System.out.println("\nId: " + customers.get(i).getId() +
                                "\nName: " + customers.get(i).getName() +
                                "\nSurname: " + customers.get(i).getSurname() + "\n");
        }
    }
    
    public static int getSize()
    {
        return customers.size();
    }
}
